feat: adding an option to exclude users from the acitivity log#2626
Open
miaulalala wants to merge 5 commits into
Open
feat: adding an option to exclude users from the acitivity log#2626miaulalala wants to merge 5 commits into
miaulalala wants to merge 5 commits into
Conversation
Collaborator
Author
|
@Aiiaiiio can you add some tests and remove the "all" option for the exclusion please? |
Signed-off-by: Tamás Bari <adaorcpp@gmail.com>
Signed-off-by: Tamás Bari <adaorcpp@gmail.com>
Signed-off-by: Tamás Bari <adaorcpp@gmail.com>
Signed-off-by: Tamás Bari <adaorcpp@gmail.com>
e8fcfb6 to
2c44647
Compare
Signed-off-by: Tamás Bari <adaorcpp@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds support for skipping activity/mailer persistence for events whose author is configured to be excluded from the activity log, and extends the unit tests to validate the new exclusion behavior.
Changes:
- Introduce
shouldSend()/isExcludedAuthor()helpers inOCA\Activity\Data. - Apply exclusion logic to
send(),storeMail(), andbulkSend()to prevent inserts when excluded. - Add PHPUnit coverage for excluded-author behavior across the three code paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
lib/Data.php |
Adds exclusion helpers and gates inserts in activity + mail queue writes based on config. |
tests/DataTest.php |
Adds data provider + tests asserting inserts are skipped/allowed depending on exclusion rules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+58
to
+72
| private function isExcludedAuthor(IEvent $event): bool { | ||
| $excludedUsers = $this->config->getSystemValue('activity_log_exclude_users', []); | ||
| if (empty($excludedUsers)) { | ||
| return false; | ||
| } | ||
| $author = $event->getAuthor(); | ||
| if ($author === '' || !isset($excludedUsers[$author])) { | ||
| return false; | ||
| } | ||
| $rule = $excludedUsers[$author]; | ||
| if (is_array($rule)) { | ||
| return in_array($event->getType(), $rule, true); | ||
| } | ||
| return false; | ||
| } |
Comment on lines
+350
to
+363
| public static function dataExcludedAuthor(): array { | ||
| return [ | ||
| // author+type match → blocked | ||
| ['alice', 'target', 'file_created', ['alice' => ['file_created']], false], | ||
| // type mismatch → allowed | ||
| ['alice', 'target', 'file_created', ['alice' => ['file_deleted']], true], | ||
| // different user → allowed | ||
| ['bob', 'target', 'file_created', ['alice' => ['file_created']], true], | ||
| // empty config → allowed | ||
| ['alice', 'target', 'file_created', [], true], | ||
| // non-array rule → allowed | ||
| ['alice', 'target', 'file_created', ['alice' => 'file_created'], true], | ||
| ]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.